package com.cykj.pos.controller.api;

import java.util.List;
import java.util.Arrays;

import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cykj.common.annotation.Log;
import com.cykj.common.core.controller.BaseController;
import com.cykj.common.core.domain.AjaxResult;
import com.cykj.common.enums.BusinessType;
import com.cykj.pos.domain.BizTransactionAmountThisMonth;
import com.cykj.pos.service.IBizTransactionAmountThisMonthService;
import com.cykj.common.utils.poi.ExcelUtil;
import com.cykj.common.core.page.TableDataInfo;

/**
 * pos1.0交易通知(本月)Controller
 *
 * @author weijianbo
 * @date 2025-03-13
 */
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/pos/month" )
public class BizTransactionAmountThisMonthController extends BaseController {

    private final IBizTransactionAmountThisMonthService iBizTransactionAmountThisMonthService;

    /**
     * 查询pos1.0交易通知(本月)列表
     */
    @PreAuthorize("@ss.hasPermi('pos:month:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizTransactionAmountThisMonth bizTransactionAmountThisMonth) {
        startPage();
        List<BizTransactionAmountThisMonth> list = iBizTransactionAmountThisMonthService.queryList(bizTransactionAmountThisMonth);
        return getDataTable(list);
    }

    /**
     * 导出pos1.0交易通知(本月)列表
     */
    @PreAuthorize("@ss.hasPermi('pos:month:export')" )
    @Log(title = "pos1.0交易通知(本月)" , businessType = BusinessType.EXPORT)
    @GetMapping("/export" )
    public AjaxResult export(BizTransactionAmountThisMonth bizTransactionAmountThisMonth) {
        List<BizTransactionAmountThisMonth> list = iBizTransactionAmountThisMonthService.queryList(bizTransactionAmountThisMonth);
        ExcelUtil<BizTransactionAmountThisMonth> util = new ExcelUtil<BizTransactionAmountThisMonth>(BizTransactionAmountThisMonth.class);
        return util.exportExcel(list, "month" );
    }

    /**
     * 获取pos1.0交易通知(本月)详细信息
     */
    @PreAuthorize("@ss.hasPermi('pos:month:query')" )
    @GetMapping(value = "/{id}" )
    public AjaxResult getInfo(@PathVariable("id" ) Long id) {
        return AjaxResult.success(iBizTransactionAmountThisMonthService.getById(id));
    }

    /**
     * 新增pos1.0交易通知(本月)
     */
    @PreAuthorize("@ss.hasPermi('pos:month:add')" )
    @Log(title = "pos1.0交易通知(本月)" , businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizTransactionAmountThisMonth bizTransactionAmountThisMonth) {
        return toAjax(iBizTransactionAmountThisMonthService.save(bizTransactionAmountThisMonth) ? 1 : 0);
    }

    /**
     * 修改pos1.0交易通知(本月)
     */
    @PreAuthorize("@ss.hasPermi('pos:month:edit')" )
    @Log(title = "pos1.0交易通知(本月)" , businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizTransactionAmountThisMonth bizTransactionAmountThisMonth) {
        return toAjax(iBizTransactionAmountThisMonthService.updateById(bizTransactionAmountThisMonth) ? 1 : 0);
    }

    /**
     * 删除pos1.0交易通知(本月)
     */
    @PreAuthorize("@ss.hasPermi('pos:month:remove')" )
    @Log(title = "pos1.0交易通知(本月)" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}" )
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(iBizTransactionAmountThisMonthService.removeByIds(Arrays.asList(ids)) ? 1 : 0);
    }
}
